package com.hk.juc.util;

import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.CyclicBarrier;

@Slf4j
public class CyclicBarrierTest3 {

    public static CyclicBarrier cyclicBarrier = new CyclicBarrier(2);

    public static void main(String[] args) throws Exception {

        Thread thread = new Thread(() -> {
            try {
                cyclicBarrier.await();
            } catch (Exception e) {
            }
        });

        thread.start();
        //中断线程
        thread.interrupt();
        try {
            cyclicBarrier.await();
        } catch (Exception e) {
            //查询此屏障是否处于损坏状态,即是否处于阻塞状态
            log.error("result: {} ",cyclicBarrier.isBroken());
        }

        thread.notify();

    }
}
